package com.restaurant.application.indexes.accumulatelist;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.restaurant.application.accumulate.Accumulate;
import com.restaurant.application.customer.Customer;
import com.restaurant.application.indexes.accumulatelist.mysql.AccumulateListTableCriteria;


public class AccumulateListDesc extends UnitDescription {

    public static void main(String[] args) {
        UnitDescription desc = UnitDescription.basicUnit(AccumulateList.class, null);
        desc
                .addUiFunction("doSearch", AccumulateListTableCriteria.class.getName())
        ;
        desc.run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("AccumulateListTable")
                .withPackageName(AccumulateListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("accumulate")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(Accumulate.class.getName())
                        .addContribution(new SQLColumn()
                                .withName("customerName")
                                .withType(DataTypes.STRING)
                                .withLabel("用户名字")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("createTime")
                                .withType(DataTypes.LONG)
                                .withLabel("时间")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("points")
                                .withType(DataTypes.LONG)
                                .withLabel("积分")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("type")
                                .withType(DataTypes.STRING)
                                .withLabel("类型")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("detail")
                                .withType(DataTypes.STRING)
                                .withLabel("积分来源详情基元")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("action")
                                .withType(DataTypes.STRING)
                                .withLabel("积分创建描述")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("customerId")
                                .withType(DataTypes.STRING)
                                .withLabel("客户Id")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("phone")
                                .withType(DataTypes.STRING)
                                .withLabel("手机号码")
                                .withWidth(255)))
                    .addContributors(new Contributor()
                            .withName("customerUID")
                            .withNullable(false)
                            .withUnique(true)
                            .withUnitType(Customer.class.getName())

                );
    }
}
